package com.hqyj.javaSpringBoot.modules.common.entity;

import org.apache.commons.lang3.StringUtils;

/**
 * @Description：SearchBean
 * @Author ：Cwd
 * @Date ：2021/8/19 16:51
 */
public class SearchBean {

    public final static int DEFAULT_CURRENT_PAGE = 1;
    public final static int DEFAULT_PAGE_SIZE = 5;

    private int currentPage;
    private int pageSize;
    private String orderBy;
    private String direction;
    private String keyword;

    public void initSearchBean(){
        if (this == null){
            return;
        }
        this.currentPage = this.currentPage == 0 ? DEFAULT_CURRENT_PAGE : this.currentPage;
        this.pageSize = this.pageSize == 0 ? DEFAULT_PAGE_SIZE : this.pageSize;
        //可在dao层中实现
        /*if (StringUtils.isBlank(this.orderBy)){
            this.orderBy = "id";
        }
        if (StringUtils.isBlank(this.direction)){
            this.orderBy = "asc";
        }
        if (StringUtils.isBlank(this.keyword)){
            this.orderBy = "";
        }*/
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public String getOrderBy() {
        return orderBy;
    }

    public void setOrderBy(String orderBy) {
        this.orderBy = orderBy;
    }

    public String getDirection() {
        return direction;
    }

    public void setDirection(String direction) {
        this.direction = direction;
    }

    public String getKeyword() {
        return keyword;
    }

    public void setKeyword(String keyword) {
        this.keyword = keyword;
    }
}
